<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:mo="https://gitee.com/aun/Timo1"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<body>

<div class="layui-card">

    <div class="layui-card-header">
        <span class="layui-icon font-s10 color-desc margin-right-5"></span>专业陪护管理
        <div class="pull-right">
<!--            <button data-table-id="NoticeTable" class="layui-btn layui-btn-primary  layui-btn-sm" data-modal="/system/user/form" data-height="720px" data-width="800px">-->
<!--                <i class=" layui-icon layui-icon-addition"></i>新建护工</button>-->
        </div>
    </div>

    <div class="layui-card-line"></div>

    <div class="layui-card-body">

        <div class="layui-card-table layui-tab">
            <div class="layui-tab-content">
                <form th:replace="/pcs/order/index_search">

                </form>
                <table id="OrderTable"  th:attr="data-url=${'/pcs/order/index?orderType='+orderType}" data-target-search="form.form-search"></table>
                <script th:inline="javascript">
                    var porterName = [[${porterName}]]
                    var orderStatus = [[${orderStatus}]]
                </script>
                <script type="text/javascript" th:inline="none">
                    $(function () {
                        $('#OrderTable').layTable({
                            even: true, height: 'full',where:{porterName:porterName,orderStatus:orderStatus},
                            cols: [[
                                {title: '序号', type: 'numbers', width: 80},
                                {field: 'sn', title: '订单编号', minWidth: 220, align: 'center'},
                                {field: 'patientName', title: '患者姓名', minWidth: 100, align: 'center'},
                                {field: 'depName', title: '病区', minWidth: 90, align: 'center'},
                                {field: 'bedNo', title: '床位', minWidth: 60, align: 'center'},
                                {field: 'projectTitle', title: '陪护名称', minWidth: 180, align: 'center'},
                                {field: 'projectStageName', title: '陪护类型', minWidth: 180, align: 'center',templet: function (d) {
                                        if(d.stageType==2){
                                            return d.hourNum+"小时陪护"
                                        }else{
                                            return d.projectStageName
                                        }
                                    }},
                                {field: 'ability', title: '自理能力', minWidth: 100, align: 'center',templet: function (d) {
                                        if (d.ability == 1) {
                                            return '基本自理';
                                        } else if (d.ability == 2) {
                                            return '半自理';
                                        } else {
                                            return '完全失能';
                                        }
                                    }},
                                {field: 'porterName', title: '陪护员', minWidth: 90, align: 'center'},
                                {field: 'price', title: '陪护费用', minWidth: 100, align: 'center'},
                                {field: 'total', title: '总费用', minWidth: 90, align: 'center'},
                                {field: 'balance', title: '累计充值', minWidth: 90, align: 'center'},
                                {field: 'orderStatus', title: '订单状态', minWidth: 100, align: 'center',templet: function (d) {
                                       let str = ""
                                        switch (d.orderStatus){
                                            case -1:
                                                str = "已取消";
                                                break;
                                            case 0:
                                                str = "待确认";
                                                break;
                                            case 1:
                                                str = "待签订合同";
                                                break;
                                            case 2:
                                                str = "服务中";
                                                break;
                                            case 3:
                                                str = "等待充值";
                                                break;
                                            case 4:
                                                str = "等待日期选择";
                                                break;
                                            case 5:
                                                str = "服务完成 待评价";
                                                break;
                                            case 6:
                                                str = "已评价";
                                                break;
                                        }
                                        return str;

                                    }},
                                {field: 'createTime', title: '创建时间', minWidth: 100, align: 'center'},
                                {field: 'companyName', title: '陪护公司', minWidth: 200, align: 'center'},
                                {toolbar: '#toolbar', title: '操作', align: 'center',minWidth: 450,  fixed: 'right'}
                            ]]
                        });
                    });



                </script>



                <script type="text/html" id="toolbar">
                    {{# if(d.orderStatus==0){ }}
                        {{# if(d.isWl==1){ }}
                        <a class="layui-btn layui-btn-sm" data-event-dbclick data-title="订单确认" data-width="1200px" data-height="650px"  shiro:hasPermission="pcs:order:add"  data-modal='/pcs/order/formWl?id={{d.id}}'>订单确认</a>
                        {{# }else{ }}
                        <a class="layui-btn layui-btn-sm" data-event-dbclick data-title="订单确认" data-width="1200px" data-height="650px"  shiro:hasPermission="pcs:order:add"  data-modal='/pcs/order/form?id={{d.id}}'>订单确认</a>
                        {{# } }}

                    <a class="layui-btn layui-btn-sm layui-bg-gray" data-event-dbclick data-confirm="确定要取消吗?" shiro:hasPermission="pcs:order:state" data-action='/pcs/order/state?id={{d.id}}&orderStatus=-1'>订单取消</a>
                    {{# } }}

                    {{# if(d.orderStatus==1){ }}
                    <a class="layui-btn layui-btn-sm layui-bg-gray" >等待合同签订</a>
<!--                    <a class="layui-btn layui-btn-sm layui-bg-gray" data-event-dbclick data-confirm="当前功能开发中....<br>点击确认按钮即代表合同已签订"  shiro:hasPermission="pcs:order:state" data-action='/pcs/order/state?id={{d.id}}&orderStatus=2'>等待合同签订</a>-->
                    {{# } }}


                    {{# if(d.orderStatus==2 || d.orderStatus==3){ }}
                    <a class="layui-btn layui-btn-sm" data-event-dbclick data-title="查看订单"  data-offset="r"  data-anim="slideLeft" data-width="90%" data-height="100%" shiro:hasPermission="pcs:order:detail"  data-modal='/pcs/order/detail?id={{d.id}}'>查看订单</a>
                        {{# if(d.orderStatus==2){ }}
                            <a class="layui-btn layui-btn-sm layui-bg-orange" data-event-dbclick data-title="更换护工" data-width="1200px"   data-modal='/pcs/order/chageporter?id={{d.id}}'>更换护工</a>
                        {{# } }}

                    <a class="layui-btn layui-btn-sm layui-bg-gray" data-event-dbclick data-confirm="确定要结束服务吗?"  shiro:hasPermission="pcs:order:state" data-action='/pcs/order/state?id={{d.id}}&orderStatus=5'>结束服务</a>
                    {{# } }}

                    {{# if(d.orderStatus==4 || d.orderStatus==-1 || d.orderStatus==5 || d.orderStatus==6){ }}
                    <a class="layui-btn layui-btn-sm" data-event-dbclick data-title="查看订单"   shiro:hasPermission="pcs:order:detail" data-offset="r"  data-anim="slideLeft" data-width="90%" data-height="100%"  data-modal='/pcs/order/detail?id={{d.id}}'>查看订单</a>
                    {{# } }}
                    {{# if(d.orderStatus>4 && (d.refundStatus==0 || d.refundStatus==3) && ((d.balance-d.total)>0)){ }}
                    <a class="layui-btn layui-btn-sm" data-event-dbclick data-title="订单退款" data-confirm="确定要退款吗? 本次退款金额为{{d.balance-d.total}}元"   data-action='/pcs/order/refund?id={{d.id}}'>订单退款</a>
                    {{# } }}
                    <a class="layui-btn layui-btn-sm" data-event-dbclick data-title="付款记录" data-width="60%"   shiro:hasPermission="pcs:order:state"  data-modal='/pcs/order/paylist?orderNo={{d.sn}}&operatorStatus=1'>付款记录</a>
                    <a class="layui-btn layui-btn-sm" data-event-dbclick data-title="退款记录" data-width="60%"   shiro:hasPermission="pcs:order:state"  data-modal='/pcs/order/refundlist?orderNo={{d.sn}}&operatorStatus=2'>退款记录</a>
                </script>

            </div>
        </div>
    </div>

</div>
</body>
</html>